import Router from 'koa-router'
// 格式转换
import IndexCon from '@/business/controller'
import {
  getListMid,
  getAddMid,
  getDetailMid,
  putMid,
  delMid,
  uploadIniMid,
  exportMid
} from '@/business/middleware/equipment/uploadIni.middleware'
import { addEditSchema, judgeIdSchema } from '@/business/schema'
import { exportExcelMid , formatHandle } from '@/business/middleware/common/common.middleware'
import EquipmentEquipmentupload from '@/mysql/model/equipment/uploadIni.model'
import { exportExcelSer } from '@/business/service'
import { addJudg, putJudg } from '@/business/schema/equipment/uploadIni.schema'
import { hasPermi } from '@/business/middleware/common/auth'

const router = new Router({ prefix: '/equipment' })
// 查询列表
router.get('/uploadini/list', hasPermi('::query'), getListMid, formatHandle, IndexCon())

// 新增
router.post(
  '/uploadini',
  hasPermi('::add'),
  addEditSchema(addJudg),
  getAddMid,
  IndexCon()
)
// 上传
router.post('/uploadini/import', hasPermi('equipment'), uploadIniMid, IndexCon('用户上传ini成功'));
// 删除
router.delete('/uploadini/:id', hasPermi('::remove'), judgeIdSchema(), delMid, IndexCon())

// 获取详细数据
router.get('/uploadini/detail/:id', hasPermi('::query'), judgeIdSchema(), getDetailMid, formatHandle, IndexCon())

// 修改
router.put(
  '/uploadini',
  hasPermi('::edit'),
  addEditSchema(putJudg),
  putMid,
  IndexCon()
)

// 导出列表(excel)
router.post(
  '/uploadini/export',
  hasPermi('::export'),
  exportExcelMid(exportExcelSer, EquipmentEquipmentupload, {}),
  exportMid,
  IndexCon()
)
export default router